let DevTools;

if (__DEV__) {

	// import { createDevTools } from 'redux-devtools'
	let createDevTools = require('redux-devtools').createDevTools;
	// import LogMonitor from 'redux-devtools-log-monitor'
	let LogMonitor = require('redux-devtools-log-monitor').default;
	// import DockMonitor from 'redux-devtools-dock-monitor'
	let DockMonitor = require('redux-devtools-dock-monitor').default;

	DevTools = createDevTools(
		<DockMonitor toggleVisibilityKey="ctrl-1" changePositionKey="ctrl-2" changeMonitorKey="ctrl-3">
			<LogMonitor theme="tomorrow" preserveScrollTop={true} />
		</DockMonitor>
	)
}

import React from 'react'

import { browserHistory } from 'react-router'
import { createStore, combineReducers, applyMiddleware, compose } from 'redux'
import thunkMiddleware from 'redux-thunk'
import { routerReducer, routerMiddleware } from 'react-router-redux'

import * as reducers from './reducers'

import { logger } from './middlewares'

const reducer = combineReducers({
  ...reducers,
  routing: routerReducer
})

let finalCreateStore;
const middleware = routerMiddleware(browserHistory)

if (DevTools) {
	finalCreateStore = compose(
		applyMiddleware(thunkMiddleware, logger, middleware),
		DevTools.instrument()
	)(createStore);
} else {
	finalCreateStore = compose(
		applyMiddleware(thunkMiddleware, logger, middleware)
	)(createStore);
}

export { DevTools };
export const store = finalCreateStore(
	reducer
)